﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.Helper;
using BCGC.BLL.BusinessObject.Resource;

public partial class Resources_TrailerDetail : PublicBasePage
{
    public static string fileInfo = string.Empty;

    private int Id
    {
        get
        {
            if (ViewState["Id"] == null)
                ViewState["Id"] = 0;
            return (int)ViewState["Id"];
        }
        set { ViewState["Id"] = value; }
    }

    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Id = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out id))
            {
                Id = id;
                LoadData();
            }
            else
                Response.Redirect(CustomSiteMap.Resources);
        }
    }

    private void LoadData()
    {
        if(Id>0)
        {
            Trailer trailer = Trailer.GetTrailerById(Id);
            if (trailer != null)
            {
                lblTrailerTitle.Text = "You are watching: " + trailer.Title;
                fileInfo = "fileName=" + trailer.FileUrl.Replace("~/", string.Empty) + "&vWidth=" + trailer.Width.ToString() + "&vHeight=" + trailer.Height.ToString();
            }
            else
                lblTrailerTitle.Text = "Sorry, no such trailer available";
        }
    }
}
